/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modulo1.cgd;

import java.util.List;
import javax.persistence.Query;
import modulo1.cdp.Professor;

/**
 *
 * @author Juan
 */
public class ProfessorDaoJpa extends DaoJpa<Professor> {
    public List<Professor> buscarNome(String nome) throws Exception {
        try {
                Query q = em.createQuery("SELECT a FROM Professor a WHERE LOWER(a.nome) LIKE LOWER('"+nome+"%') ");
            return q.getResultList();
        }
        catch (Exception ex) {
            throw ex;
        }
    }
    
    public Professor verificarProfessor(String cpf, String senha) throws Exception {
        try {
                Query q = em.createQuery("SELECT p FROM Professor p WHERE p.cpf = '"+cpf+"' AND p.senha = '"+senha+"' ");
            return (Professor)q.getResultList().get(0);
        }
        catch (Exception ex) {
            throw ex;
        }
    }
}
